import request from "@/utils/request";

enum URLS {
  LIST = "/product/baseTrademark",
}

//类型1:单个品牌的数据类型
export interface typeRecord {
  id: number;
  tmName: string;
  logoUrl: string;
}
export interface typePageInfo<T> {
  records: T;
  total: number;
  size: number;
  current: number;
  pages: number;
}

//类型1: 请求品牌列表返回值类型
export type ResTrademarkByPage = typePageInfo<typeRecord[]>;


//请求1:请求品牌列表(分页)数据
export function requestTrademarkListByPage(page = 1, limit = 3) {
  return request.get<any,ResTrademarkByPage>(`${URLS.LIST}/${page}/${limit}`);
}


//类型2: 添加品牌请求参数 Omit是ts提供的,通过从中选取属性然后删除（字符串文本或字符串文本的联合）来构造类型
export type addBaseTrademark = Omit<typeRecord,"id">
//请求2: 添加品牌请求
export const requestSaveBaseTrademark = (data:addBaseTrademark)=>{
  return request.post<any, null>(`/product/baseTrademark/save`,data)
}

//类型3:编辑品牌 请求参数
export type updateBaseTrademark = typeRecord
//请求3:编辑品牌请求
export const requestUpdateTrademark = (data:updateBaseTrademark)=>{
  return request.put<any,null>(`/product/baseTrademark/update`,data)
}


//请求4:删除品牌
export const requestDeleteTrademark = (id:number)=>{
  return request.delete<any,null>(`/product/baseTrademark/remove/${id}`)
}

//请求5:获取所有品牌列表
export const requestAllTrademarkInfo = ()=>{
  return request.get<any,typeRecord[]>(`/product/baseTrademark/getTrademarkList`)
}